<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
<div id="app">
    <button @click="showc">显示仓库的内容</button>
    <h1>{{this.$store.state.count}}</h1>
    <button @click="add">加1</button>
</div>

<script src="node_modules/vue/dist/vue.js"></script>
<script src="node_modules/vuex/dist/vuex.js"></script>

<script>

    //定义一个常量
    let INCREATE = "increate";

    let store = new Vuex.Store({
        state:{
            count:567
        },
        mutations:{
            [INCREATE]:function(state){
                state.count += 1;
            }
        }
    })

    var vm = new Vue({
        el:"#app",
        data:{
            count:0
        },
        store,//
        methods: {
            showc:function(){
                console.log(this.$store);
            },
            add:function(){
                //提交commit修改数据
                this.$store.commit("increate");
            },
        }
    })
</script>

</body>
</html>